﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication3
{
    public partial class Risultati : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            using (DataClasses1DataContext ctx = new DataClasses1DataContext())
            {
                var _candidati = ctx.Tables.OrderByDescending(c => c.preferenze).ThenBy(c => c.nome).ToList();

                var totale = _candidati.Sum(c => c.preferenze);

                litTotale.Text = totale.ToString();

                rptCandidati.DataSource = _candidati;
                rptCandidati.DataBind();
            }

        }
    }
}